package com.xlhj.boot.webservice.rs.client.service;

import com.xlhj.boot.webservice.rs.api.entity.UserInfo;
import org.apache.cxf.jaxrs.client.WebClient;
import org.springframework.stereotype.Component;

import javax.ws.rs.core.Response;

/**
 * @Author: caijliu
 * @Date: 06/12/2021 14:41
 * @Description TODO
 * @Vsersion: 0.0.1
 */
@Component
public class UserInfoApiClient {

    private static final String ADDRESS = "http://localhost:8335/services/userInfoService";

    public Response saveUserInfo(UserInfo userinfo) {
        return WebClient.create(ADDRESS).post(userinfo);
    }

    public Response updateUserInfo(UserInfo userInfo) {
        return WebClient.create(ADDRESS).put(userInfo);
    }

    public Response deleteUserById(Long id) {
        return WebClient.create(ADDRESS + "/" + id).delete();
    }

    public Response findAllUser() {
        return WebClient.create(ADDRESS).get();
    }

    public Response findUserInfoById(Long id) {
        return WebClient.create(ADDRESS + "/" + id).get();
    }
}
